/**
 * 
 */
package org.cuatrovientos.struts;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;



/**
 * Hello simple sample Struts2 action which just greets you
 * @author Pablo Guerrero
 *
 */
public class Home extends ActionSupport {
	private List<Car> carList = new ArrayList<Car>();
	private String message;
	private String fullmessage;
	private int total;
	
	/**
	 * @return the fullmessage
	 */
	public String getMessageall() {
		return fullmessage;
	}

	/**
	 * @param fullmessage the fullmessage to set
	 */
	public void setMessageall(String fullmessage) {
		this.fullmessage = fullmessage;
	}

	/* (non-Javadoc)
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	@Override
	public String execute() throws Exception {
		message = "Welcome to hell";
		
		carList.clear();
		CarDAO carDAO = new CarDAO();
		carList.addAll(carDAO.selectAll());
	
		total = carList.size();
		fullmessage = Integer.toString(total);
		
		return SUCCESS;
	}

	/**
	 * @return the message
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * @param message the message to set
	 */
	public void setMessage(String message) {
		this.message = message;
	}

	/**
	 * @return the fullmessage
	 */
	public String getFullmessage() {
		return fullmessage;
	}

	/**
	 * @param fullmessage the fullmessage to set
	 */
	public void setFullmessage(String fullmessage) {
		this.fullmessage = fullmessage;
	}

	/**
	 * @return the total
	 */
	public int getTotal() {
		return total;
	}

	/**
	 * @param total the total to set
	 */
	public void setTotal(int total) {
		this.total = total;
	}
	
}
